package code.simulation;

/*Singleton class*/
public class IDSetter {

	static short setter = 1;
	private static IDSetter idSetter;

	public IDSetter() {

	}

	public static IDSetter getInstance() {

		if (idSetter == null) {
			idSetter = new IDSetter();
		}

		return idSetter;
	}

	public static short produceID() {
		return setter++;
	}

	public static String produceAddress(String subNet) {

		String addressProduced = subNet + produceID();
		return addressProduced;
	}
	
	public static short produceID(String address) {
		String ip[] = address.split("\\.");
		return Short.parseShort(ip[ip.length-1]);
	}
}
